#include<stdio.h>
typedef struct {
	int numitor;
	int numarator;
} Rational;

Rational produs(Rational,Rational);
Rational suma(Rational,Rational);
Rational diff(Rational,Rational);
Rational q(Rational,Rational);
int cmmdc (int,int);
Rational simplifica(Rational);
Rational ordin2(Rational d,Rational e);
Rational power(Rational d,Rational e);

int main ()
{
	Rational a,b,d,e;
	a.numarator=1;
	a.numitor=2;
	b.numarator=1;
	b.numitor=4;
	d.numarator=6;
	e.numitor=7;
	Rational rezultatOperatie;
	rezultatOperatie=produs(a,b);
	Rational rezultatOrdin2;
	rezultatOrdin2=ordin2(d,e);
	Rational c=q(a,b);
	printf("\n%d | %d\n",c.numarator,c.numitor);
	printf ("\n%d / %d\n",
rezultatOperatie.numarator,rezultatOperatie.numitor);
	printf ("\n%d / %d\n",
rezultatOrdin2.numarator,rezultatOrdin2.numitor);
	Rational rezultatpow;
	rezultatpow=power(d,e);
	printf ("\n%d | %d\n",
rezultatpow.numarator,rezultatpow.numitor);
	return 0;
}

Rational simplifica(Rational p)
{
	Rational r;
	r.numarator=p.numarator/cmmdc(p.numarator,p.numitor);
	r.numitor=p.numitor/cmmdc(p.numarator,p.numitor);
	return r;
}

int cmmdc(int n,int m)
{
	int r;
	r=n%m;
	while(r!=0)
	{
		n=m;
		m=r;
		r=n%m;
	}
	return r;
}

Rational produs(Rational a,Rational b)
{
	Rational r;
	r.numarator=a.numarator*b.numarator ;
	r.numitor=a.numitor*b.numitor;
	return simplifica(r);
}

Rational suma(Rational a,Rational b)
{
	Rational r;
	r.numarator=a.numarator*b.numitor+a.numitor*b.numarator;
	r.numitor=a.numitor*b.numitor;
	return simplifica(r);
}

Rational diff(Rational a,Rational b)
{
	b.numarator=-b.numarator;
	return suma(a,b);
}

Rational q(Rational a,Rational b)
{
	Rational t;
	t.numarator=b.numitor;
	t.numitor=b.numarator;
	return produs(a,t);
}

Rational ordin2(Rational d,Rational e)
{
	Rational r;
	r.numarator=d.numarator*d.numarator ;
	r.numitor=e.numitor*e.numitor;
	return simplifica(r);
}

Rational power(Rational d,Rational e)
{
	Rational r;
	int x=2;
	r.numarator=d.numarator^x;
	r.numitor=e.numitor^x;
	return simplifica(r);
}
